package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.zr.service.FuncService;

@Controller
@Scope(value="prototype")
public class FuncAction extends ActionSupport implements ServletResponseAware{
	private HttpServletResponse resq;
	@Resource
	private FuncService funcService;
	@Override
	public void setServletResponse(HttpServletResponse response) {
		// TODO Auto-generated method stub
		this.resq=response;
	}
	public void showFunc() {
		int parentid=funcService.findFunId();
		try {
			resq.setCharacterEncoding("utf8");
			PrintWriter pw=resq.getWriter();
			pw.write(funcService.getAllFunc(parentid).toString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
